package com.information.manage.maintenance.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.information.manage.basic.common.result.Result;
import com.information.manage.maintenance.model.dto.MailInfoDTO;
import com.information.manage.maintenance.model.dto.MaintenancePlanDTO;
import com.information.manage.maintenance.model.entity.Equipment;
import com.information.manage.maintenance.model.query.MaintPageQuery;
import com.information.manage.maintenance.model.query.StaffQuery;
import com.information.manage.maintenance.model.vo.MaintenanceMenuVo;
import com.information.manage.maintenance.model.vo.MaintenancePlanVo;
import com.information.manage.maintenance.service.EquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import sun.util.resources.cldr.zh.CalendarData_zh_Hans_HK;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@RestController
@RequestMapping("/maintenance/")
public class EquipmentController {

    @Resource
    private EquipmentService equipmentService;


    @GetMapping("menu")
    public Result<List<MaintenanceMenuVo>> Menu() {
        return Result.ok(equipmentService.getMenu());
    }

    @GetMapping("list")
    public Result<Page<MaintenancePlanVo>> MaintList(MaintPageQuery pageQuery){
        log.info("get==->{} ",pageQuery);
        return Result.ok(equipmentService.getMaintList(pageQuery));
    }

    @PostMapping("mail")
    public void Mail(@RequestBody MailInfoDTO mailInfoDTO){
        log.info("get -=== {}" ,mailInfoDTO);
        equipmentService.sendMail(mailInfoDTO.getMaint(),mailInfoDTO.getDay(),mailInfoDTO.getMailTo());
    }

    @GetMapping("staff")
    public Result<List<StaffQuery>> Staff(){
        return Result.ok(equipmentService.getStaffList());
    }

}
